package com.example.blog.controller;

import com.example.blog.model.User;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/mongodb/hello")
public class HelloMongoController {
    private final MongoTemplate mongoTemplate;

    public HelloMongoController(MongoTemplate mongoTemplate) {
        this.mongoTemplate = mongoTemplate;
    }

    @GetMapping
    public List<User> getBlog(){
        return mongoTemplate.findAll(User.class);
    }
}

